﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Workflow.Alerts;
using Sitecore.Data.Items;
using System.Threading;

namespace Workflow.Layout.Layouts
{
    public partial class CreateMunicipality : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            WorkflowFilter filter = new WorkflowFilter()
            {
                FirstName = txtFirstName.Text,
                LastName = txtLastName.Text,
                Phone1 = txtPhone1.Text,
                Phone2 = txtPhone2.Text,
                Email = txtEmail.Text,
                Login = txtLogin.Text,
                Password = txtPassword1.Text,
                PostCity = txtPostCity.Text,
                PostAddress = txtPostAddress.Text,
                PostCode = txtPostCode.Text,
                Name = txtMunicipalityName.Text,
                CenterCoordinates = txtCoordinates.Text
                
            };

            UserDAL dal = new UserDAL();
            dal.CreateMunicipalityUser(new WorkflowFilterSql(filter));
            createuser.Visible = false;
            message.Visible = true;

            ////copy sitecore node


            
            

            Item rootItem = Sitecore.Context.Database.GetItem("/sitecore/content/workflow");
            rootItem.Add(txtMunicipalityName.Text,new Sitecore.Data.BranchId(new Sitecore.Data.ID("1B378D2F-913C-41C5-A8B1-3E1420722070")));

            
            //Item templateItem = Sitecore.Context.Database.GetItem("/sitecore/content/workflow/MunicipalityTemplate/Municipality");
            
            //rootItem.Add(txtMunicipalityName.Text, new TemplateItem(templateItem));
           
        }
    }
}
